#include <iostream>
using namespace std;
#define MaxSize 50

typedef struct int_Share_Stack
{
    int data[MaxSize];
    int top1 = -1;
    int top2 = -1;
} ISS;

bool push(ISS *stack, int stackNum, int n)
{
    if (stack->top1 + stack->top2 == MaxSize - 2)
        return false;
    int index = stackNum == 1 ? (++stack->top1) : (MaxSize-1 - ++stack->top2);
    stack->data[index] = n;
    return true;
}
bool push1(ISS *stack, int n) { return push(stack, 1, n); }
bool push2(ISS *stack, int n) { return push(stack, 2, n); }

int pop(ISS *stack, int stackNum)
{
    int index = stackNum == 1 ? (stack->top1) : (stack->top2);
    if (index == -1) return -1;
    index = stackNum == 1 ? (stack->top1--) : (MaxSize - stack->top2--);
    return stack->data[index];
}

int pop1(ISS *stack) { return pop(stack, 1); }
int pop2(ISS *stack) { return pop(stack, 2); }


int top(ISS *stack, int stackNum)
{
    int index = stackNum == 1 ? (stack->top1) : (stack->top2);
    if (index == -1) return -1;
    index = stackNum == 1 ? (stack->top1) : (MaxSize - stack->top2);
    return stack->data[index];
}
int top1(ISS *stack) { return top(stack, 1); }
int top2(ISS *stack) { return top(stack, 2); }

ISS *init()
{
    ISS *stack = new ISS();
    push1(stack, 2);
    push1(stack, 2);
    push2(stack, 2);
    push2(stack, 2);
    return stack;
}
int main(int argc, char const *argv[])
{
    ISS *s = init();
    printf("%d,%d", pop1(s), top2(s));
    return 0;
}
